Component({
  data: {
    selected: 0,
    color: "#333 ",
    selectedColor: "#FE814A",
    borderStyle: "white",
    list: [
      {
        "pagePath": "/pages/index/index",
        "text": "首页",
        "iconPath":"/img/tabBar/index.png",
        "selectedIconPath":"/img/tabBar/index1.png"
      },
      {
        "pagePath": "/pages/typePage/typePage",
        "text": "分类",
        "iconPath":"/img/tabBar/typePage.png",
        "selectedIconPath":"/img/tabBar/typePage1.png"
      },
      {
        "pagePath": "/pages/saoPay/saoPay",
        "text": "扫码购",
        "iconPath":"/img/tabBar/saoma.png",
        "selectedIconPath":"/img/tabBar/saoma.png"
      },
      {
        "pagePath": "/pages/shopCart/shopCart",
        "text": "购物车",
        "iconPath":"/img/tabBar/shopCart.png",
        "selectedIconPath":"/img/tabBar/shopCart1.png"
      },
      {
        "pagePath": "/pages/personCenter/personCenter",
        "text": "我的",
        "iconPath":"/img/tabBar/my.png",
        "selectedIconPath":"/img/tabBar/my1.png"
      }
    ],
    wpxIos:false
  },
  attached() {
    let that=this
    // 判断是否为苹果X
    this.setData({
      wpxIos: getApp().globalData.wpxIos
    })
  },
  methods: {
    switchTab(e) {
      if (e.currentTarget.dataset.path=='/pages/saoPay/saoPay') {
        this.onSao()
        return 
      }
      const data = e.currentTarget.dataset
      const url = data.path
      wx.switchTab({url})
      // this.setData({
      //   selected: data.index
      // })
      
    },
      
    // 扫一扫
    onSao: function(e) {
        wx.scanCode({　
            success: (res) => {　　
             console.log(res);
             let id=decodeURIComponent(res.result).split("?goods_id=")[1]
             wx.navigateTo({
               url: '/pages/goodsDetail/goodsDetail?goods_id='+id,
             })
            }　
        })
    },
  }
})